
//布局的对象,全局
var layout, tab, accordion;

//获取QueryString的数组
function getQueryString()
{
    var result = location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+", "g"));
    if (result == null)
    {
        return "";
    }
    for (var i = 0; i < result.length; i++)
    {
        result[i] = result[i].substring(1);
    }
    return result;
}
//根据QueryString参数名称获取值
function getQueryStringByName(name)
{
    var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1)
    {
        return "";
    }
    return result[1];
}
//根据QueryString参数索引获取值
function getQueryStringByIndex(index)
{
    if (index == null)
    {
        return "";
    }
    var queryStringList = getQueryString();
    if (index >= queryStringList.length)
    {
        return "";
    }
    var result = queryStringList[index];
    var startIndex = result.indexOf("=") + 1;
    result = result.substring(startIndex);
    return result;
}

(function ($)
{

    //全局事件
    $(".l-dialog-btn").live('mouseover', function ()
    {
        $(this).addClass("l-dialog-btn-over");
    }).live('mouseout', function ()
    {
        $(this).removeClass("l-dialog-btn-over");
    });
    $(".l-dialog-tc .l-dialog-close").live('mouseover', function ()
    {
        $(this).addClass("l-dialog-close-over");
    }).live('mouseout', function ()
    {
        $(this).removeClass("l-dialog-close-over");
    });
    //搜索框 收缩/展开
    $(".searchtitle .togglebtn").live('click',function(){ 
        if($(this).hasClass("togglebtn-down")) $(this).removeClass("togglebtn-down");
        else $(this).addClass("togglebtn-down");
        var searchbox = $(this).parent().nextAll("div.searchbox:first");
        searchbox.slideToggle('fast');
    }); 

})(jQuery);


function changeTnf(obj){
	obj.checked==true?obj.value='T':obj.value='F';
}


function changeTnfToStore(eleObj,Id,uri){
	var enable=eleObj.checked==true?'T':'F';
	$.ajax({
		type : "GET",
		url :  uri,
		data:{id:Id,isEnable:enable},
		success : function(result) {
            if (!result.success) {
            	$.ligerDialog.alert(result.message,'错误','error');
            }
            else {
            	$.ligerDialog.alert(result.message,'提示','success');
            }	
		}
	});
}

/*
 * 
 不要使用这种方式,与ligerUI冲突
Array.prototype.contains=function(obj){
	return containsArray(this,obj);
}
*/
function containsArray(array,obj){  
	for(var i=0;i<array.length;i++){   
		if(array[i]==obj){   
        	return true;   
         }   
	}   
	return false;   
}

getIndexByValue=function(array,value){
    var index = -1;  
    for (var i = 0; i < array.length; i++)  
    {  
        if (array[i] == value)  
        {  
            index = i;  
            break;  
        }  
    }  
    return index;
}
  
function removeFromArray(array,value){
	var index=getIndexByValue(array,value);
	array.splice(index,1);
}


function clearArray(array){
	this.length=0;
}


/*var alert = function (content)
{
    $.ligerDialog.alert(content);
    
};
*/
//查询可视化窗口大小，文档的水平垂直滚动距离
function getWinGeometry(win){
    //all browser but IE
	var geometry = {};
    if(win.innerWidth!=undefined){
           geometry.width =win.innerWidth;
           geometry.height = win.innerHeight;
    }
    //IE
    else if(win.document.documentElement!=undefined && win.document.documentElement.clientWidth!=undefined){
           geometry.width = win.document.documentElement.clientWidth;
           geometry.height = win.document.documentElement.clientHeight;
    }
    //IE6 without a DOCTYPE
    else if(win.document.body.clientWidth!=undefined){
           geometry.width = win.document.body.clientWidth;
           geometry.height = win.document.body.clientHeight;
    }
    return geometry;
}

